//
//  UUHybridSelectPackageHandler.m
//  UUCharterSupplier
//
//  Created by ZhangAo on 27/02/2018.
//  Copyright © 2018 UUCharter. All rights reserved.
//

#import "UUHybridSelectPackageHandler.h"
#import "UUProductPackagePicker.h"
#import "UUProductManager.h"

@implementation UUHybridSelectPackageBaseHandler

- (UUProductPackageType)packageType {
    return UUProductPackageTypeDay;
}

- (NSString *)name {
    if ([self packageType] == UUProductPackageTypeDay) {
        return @"selectPackage";
    } else {
        return @"selectline";
    }
}

- (void)executeWithParams:(id)params callbackWith:(void (^)(id))callback {
    UIViewController *picker = [UUProductPackagePicker pickerWithPackageType:[self packageType]
                                                               completeBlock:^(NSNumber *packageId) {
                                                                   UUProductPackageModel *package = [GetProductManager() fetchProductPackageModelWithPackageId:packageId];
                                                                   
                                                                   callback(@{
                                                                              @"spec_id" : packageId,
                                                                              @"name" : package.name,
                                                                              @"is_half_day" : @(package.isHalfDay),
                                                                              });
                                                               }];
    
    [self.context.hostVC presentViewController:picker animated:YES completion:nil];
}

@end

@implementation UUHybridSelectPackageHandler


@end
